package com.shilei.spring;

import com.shilei.spring.annotation.Component;
import com.shilei.spring.annotation.LogAuto;
import com.shilei.spring.annotation.Refresh;
import com.shilei.spring.annotation.Value;
import com.shilei.spring.util.AopUtil;
import com.shilei.spring.util.BeanUtil;


/**
 * @author 石雷
 * shilei1@jiayuan.com
 * 2021/8/24/024 16:56
 */
@LogAuto
@Refresh
@Component
public class Test {

    @Value(key = "key")
    private String value;

    @Value(key = "test")
    private String test;

    public static void main(String[] args) throws Exception {
        //1.模拟包扫描 初始化bean
        BeanUtil.initBeans("com.shilei.spring");
        BeanUtil.getValues("com.shilei.spring");

        //2.动态代理实现aop
        AopUtil.initProxy("com.shilei.spring");

        //3.模拟di注入 @value注解 注入值
        BeanUtil.DI("com.shilei.spring");

        //5.测试aop
        Test bean = BeanUtil.getBean(Test.class);
        bean.test();

//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                //6.监控配置文件变化并 调用传入对象方法刷新@value注入的值
//                try {
//                    PropertiesUtil.callBack(new Callback());
//                } catch (IOException e) {
//                    e.printStackTrace();
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//            }
//        }).start();



    }



    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public void test(){
        System.out.println("test");
    }
}
